#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/1/22 0:10
# @File     : kc16_06.py
# @Project  : jt808
def parse_06_Billing_Model_Verification_Request_Response(body):
    # 解析 0x06 计费模型验证请求应答
    data = {
        "桩编号": body[0:14],
        "计费模型编号": billing_model_code(body) + "(" + body[14:18] + ")",
        "验证结果": verify_result(body[18:20]) + "(" + body[18:20] + ")",
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def billing_model_code(body):
    # 如果等于0则返回"首次连接平台"，其他则返回值
    return "首次连接平台" if int(body[14:18], 16) == 0 else body[14:18]


def verify_result(result):
    return "桩计费模型与平台一致" if result == "00" else "桩计费模型与平台不一致" if result == "01" else "未知结果"


__all__ = ['parse_06_Billing_Model_Verification_Request_Response']
